package com.jingdianjichi.wx.handler;

import com.jingdianjichi.wx.enums.MsgTypeEnum;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class SubscribeMsgHandler implements MsgTypeHandler{
    @Override
    public MsgTypeEnum getByMsgType() {
        return MsgTypeEnum.SUBSCRIBE;
    }

    @Override
    public String handle(Map<String, String> map) {
        String fromUserName = map.get("FromUserName");
        String toUserName = map.get("ToUserName");
        String relayString = "你好 欢迎关注 我是cosx";
        String msg = "<xml>\n" +
                "  <ToUserName><![CDATA["+fromUserName+"]]></ToUserName>\n" +
                "  <FromUserName><![CDATA["+toUserName+"]]></FromUserName>\n" +
                "  <CreateTime>12345678</CreateTime>\n" +
                "  <MsgType><![CDATA[text]]></MsgType>\n" +
                "  <Content><![CDATA["+relayString+"]]></Content>\n" +
                "</xml>";

        return msg;
    }
}
